/**
 * @Description: questionController
 * @Author: Mr.Niu
 * @Date: 2022/9/20 17:20
 */
package com.zhiyou.crud.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhiyou.crud.bean.Question;
import com.zhiyou.crud.service.NewsService;
import com.zhiyou.crud.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class QuestionController {
    @Autowired
    QuestionService questionService;
    @Autowired
    NewsService newsService;
    //问题咨询
    @RequestMapping("/question")
    public String getquestion(@RequestParam(value="pn", defaultValue="1") Integer pn , Model model ,HttpSession session){
        //传入页码和每页显示的数量
        PageHelper.startPage(pn,5);
        List<Question> getqus = questionService.getqus();
        model.addAttribute("cop",getqus);
        //5是连续显示5页的内容
        PageInfo pages=new PageInfo(getqus,5);
        model.addAttribute("pages",pages);
        Integer[] getallnews=newsService.getddj();
        session.setAttribute("ddj", getallnews);
        return "cop";
    }
}
